package cn.flying.cloud.base.core.undertow;

import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.undertow.UndertowOptions;

/**
 * Undertow 配置类
 *
 * @author: admin
 * @date: 2025年02月21日 23:16
 * @version: 1.0
 */
@Configuration
public class UndertowConfiguration {

    /**
     * Undertow配置
     *
     * @return
     */
    @Bean
    public UndertowServletWebServerFactory embeddedServletContainerFactory() {
        UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
        factory.addBuilderCustomizers(builder -> {
            // 配置header大小，也可以采用yml
            // undertow:
            //    options:
            //      max-header-size: 10485760
            builder.setServerOption(UndertowOptions.MAX_HEADER_SIZE, 100 * 1024 * 1024); // 增加请求头最大大小
        });
        return factory;
    }
}